//
// Created by liangwenhao on 2024/4/4.
//

#include "can_send_task.h"
//空电流，用于关控保护
CAN_Send  can1_temp;
CAN_Send  can2_temp;
//can发送结构体
CAN_Send  can1Tx_0x200={};
CAN_Send  can1Tx_0x1FF;
CAN_Send  can2Tx_0x200;
CAN_Send  can2Tx_0x1FF;
void can_send_init()//注意can发送格式
{
    can1_temp.SendID = 0x200;
    for(int i = 0; i < 8; i++)
    {
        can1_temp.SendData[i]=0;
    }

    can2_temp.SendID = 0x200;
    for(int i = 0; i < 8; i++)
    {
        can2_temp.SendData[i]=0;
    }
}

uint32_t can1_cnt = 0;
void CAN1Send_Control(void *argument)
{
    //__nop()
    CAN_Send_Init(&can1Tx_0x200);
    for(;;)
    {
        osDelay(1);
        can1_cnt++;
        if(RC_Ctl.Rc_Dog.rc_dog<1)
        {
            //can1Tx_0x200.SendData[0] = can1Tx_0x200.SendData[1] = 0;
            //can1Tx_0x200.SendData[4] = can1Tx_0x200.SendData[5] = 0;
            CAN1_Send_Msg(&can1Tx_0x200, 8);
        } else {
            CAN1_Send_Msg(&can1_temp, 8);
        }

    }
}

void CAN2Send_Control(void *argument)
{
    CAN_Send_Init(&can2Tx_0x200);
    for(;;)
    {
        osDelay(1);
        if(RC_Ctl.Rc_Dog.rc_dog<1)
        {
            CAN2_Send_Msg(&can2Tx_0x200, 8);
        }
        else
        {
            CAN2_Send_Msg(&can2_temp, 8);
        }
    }
}